level: any
What is Eddie?
Eddie is a new code editor written in Liberty BASIC, for Liberty BASIC. Eddie can be customized and extended to meet the needs of the individual programmer. The newest version is available here: Eddie!
Removing the Context Menu
CodeAChrome comes with an automatic context menu that is invoked when the user clicks the right mouse button in the edit portion of the control. This menu has edit functions, which is good, but it also has file input/output functions. In some cases, that would be good, too, but not in Eddie. Eddie likes to know when a new file is opened and loaded into the editor, so that it can be parsed for branch labels, which are added to the branch label combobox. If the user opens a file by using the context menu, Eddie has no way of knowing that!
Since Eddie has all the functions needed for editing, file input/output and finding and replacing text, we can remove the context menu from CodeAChrome. It's very easy to turn that menu on and off with a call to SetContextMenuOn. If the argument is 0, the menu is turned off. If it is 1, the menu is turned on.
calldll #r, "SetContextMenuOn",_ 'right-click menu
0 as long,_ '1 = on, 0 = off
ret as void 'no return
User Customization Functions
We've added an Options Menu to Eddie to allow the user to customize it to his liking.
Menu #1, "&Options", "&Syntax Color",[syntaxColor],"&Line Numbers",[lineNumbers]
The user can turn syntax coloring and line numbers on or off.
What is Syntax Color?
The Liberty BASIC IDE allows you to see code in color, and so does Eddie. Syntax coloring means that keywords are displayed in one color, quoted strings are displayed in another color, comments in a third color, and so on. CodeAChrome has a built-in list of typical keywords that are used in many programming languages. These words include print, gosub, if, etc. Syntax colored code looks like this:

In a future installment of Eddie, we'll see how to customize the list of keywords, but for now, we'll use the default list. CodeAChrome also allows us to customize the syntax colors and we'll do that in a future installment of Eddie, too!
Toggling Syntax Color
Eddie and CodeAChrome show source code with syntax colors, by default. CodeAChrome has a function to turn sytnax coloring on or off, called SetSyntaxColorOn. Just as for the context menu, if the argument sent to the function is 0, the syntax coloring is turned off. If it is 1, the syntax coloring is turned on.
calldll #r, "SetSyntaxColorOn",_ 'use syntax coloring
togglecol as long,_ '1 = on, 0 = off
ret as void 'no return
Here is the routine in Eddie that allows the user to choose whether or not he wants to see the source code with syntax coloring. It uses a CONFIRM message to ask the user what he wants, then sets the syntax coloring on or off accordingly, and finally sets focus to CodeAChrome.
[syntaxColor]
confirm "Use syntax colors?";ans$
if ans$ = "yes" then togglecol = 1 else togglecol = 0
calldll #r, "SetSyntaxColorOn",_ 'use syntax coloring
togglecol as long,_ '1 = on, 0 = off
ret as void 'no return
calldll #r, "DoSetFocus", re as void
wait
Toggling Line Numbers
Eddie and CodeAChrome have a line number margin on the left side, by default. CodeAChrome has a function to turn this margin on or off, called SetLineNumbersOn. Just as for the context menu, if the argument sent to the function is 0, the line number margin is turned off. If it is 1, the line number margin is turned on.
calldll #r, "SetLineNumbersOn",_ 'use line numbers?
togglelines as long,_ '1 = on, 0 = off
ret as void 'no return
Here is the routine in Eddie that allows the user to choose whether or not he wants to see the line number margin. It uses a CONFIRM message to ask the user what he wants, then sets the line numbers on or off accordingly, and finally sets focus to CodeAChrome.
[lineNumbers]
confirm "Use line numbers?";ans$
if ans$ = "yes" then togglelines = 1 else togglelines = 0
calldll #r, "SetLineNumbersOn",_ 'use line numbers?
togglelines as long,_ '1 = on, 0 = off
ret as void 'no return
calldll #r, "DoSetFocus", re as void
wait
There's More!
Watch for more features of CodeAChrome in future versions of Eddie.